import { createRouter, createWebHashHistory } from 'vue-router'
// @ts-ignore
import { routes, handleHotUpdate } from 'vue-router/auto-routes'
// @ts-ignore
import { setupLayouts } from 'virtual:generated-layouts'

export const router = createRouter({
    history: createWebHashHistory(),
    routes: setupLayouts(routes),
})

console.log(router)

router.beforeEach(async (to, from) => {
    // if (to.meta.noAuth)
    // if (
    //   // make sure the user is authenticated
    //   !isAuthenticated &&
    //   // ❗️ Avoid an infinite redirect
    //   to.name !== 'Login'
    // ) {
    //     // redirect the user to the login page
    //     return { name: 'Login' }
    // }
})

// This will update routes at runtime without reloading the page
if (import.meta.hot) {
    handleHotUpdate(router)
}